<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>权限节点列表</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <include file="Index/common_css"/>
    <link href="__PUBLIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <!--分页样式-->
    <style type="text/css">
        div.green-black{padding:3px;margin:3px;text-align:center;}
        div.green-black a{border:#2c2c2c 1px solid;padding:2px 5px;background:#2c2c2c;color:#fff;margin:0 2px 0 0;text-decoration:none;}
        div.green-black a:hover{border: #23b7e5 1px solid;background: #23b7e5;color:#fff;}
        div.green-black a:active{border: #23b7e5 1px solid;background: #23b7e5;color:#fff;}
        div.green-black span.current{border: #23b7e5 1px solid;padding:2px 5px;font-weight:bold;background:#23b7e5;color:#fff;margin:0 2px 0 0;}
        div.green-black span.disabled{border:#f3f3f3 1px solid;padding:2px 5px;color:#ccc;margin:0 2px 0 0;}
        .search_checkbox{  margin: 0;  padding: 0;  margin-left: 15px;  display: inline-block;  height: 30px;  padding-top: 12px;  }
        .search_checkbox input[type=checkbox]{  height: 0px;  width: 0px;  visibility: hidden;  }
        .search_checkbox label{  cursor: pointer;  height: 20px;  border-radius: 10px;  display: inline-block;  background-color: gray;  width: 40px;  text-indent: -99999px;  position: relative;  }
        .search_checkbox label::before {  content: '';  display:inline-block;  background-color: white;  height: 15px;  width: 15px;  position: absolute;  top: 2.5px;  left: 2.5px;  border-radius: 7px;  transition:0.3s;  }
        .search_checkbox input:checked + label {background: #bada55;}
        .search_checkbox input:checked + label:before {left: calc(100% - 2.5px);transform: translateX(-100%);}
        .search_checkbox label:active:before{width:20px;}
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>权限节点列表</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link"  href="javascript:location.replace(location.href);" title="刷新">
                            <i class="fa fa-refresh"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-1 m-b-xs">
                            <a  onclick="power_add('节点添加','__MODULE__/System/power_add',800,350);" class="btn btn-w-m btn-success">添加</a>
                        </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th> </th>
                                <th>ID</th>
                                <th>节点名称</th>
                                <th>节点链接</th>
                                <th>所属节点</th>
                                <if condition="$admin['user_role'] eq 5">
                                    <th>开关节点</th>
                                </if>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <foreach name="data" item="data">
                                <tr>
                                    <td>
                                        <!--<input type="checkbox" class="i-checks" name="input[]">-->
                                    </td>
                                    <td>{$data.menu_id}</td>
                                    <td>{$data.menu_name}</td>
                                    <td>{$data.menu_href}</td>
                                    <td>{$data.menu_parent}</td>
                                    <if condition="$admin['user_role'] eq 5">
                                        <td>
                                            <div class='search_checkbox'>
                                                <input onchange="switch_off(this,'{$data.menu_id}')" type='checkbox' <if condition="$data.switch eq 1">checked</if> id= 'switch_{$data.menu_id}'>
                                                <label for='switch_{$data.menu_id}'></label>
                                            </div>
                                        </td>
                                    </if>
                                    <td>
                                        <a title="编辑" onclick="Power_save('编辑','__MODULE__/System/power_save/menu_id/{$data.menu_id}',800,400);"><i class="fa fa-search-plus text-navy"></i></a>
                                        <a title="删除"  onclick="Power_delete(this,'{$data.menu_id}');"><i class="fa fa-trash text-navy"></i></a>
                                    </td>
                                </tr>
                            </foreach>
                            </tbody>
                        </table>
                        <div class="green-black">{$page}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
<include file="Index/common_js"/>
<!-- Peity -->
<script src="__PUBLIC__/admin/js/plugins/peity/jquery.peity.min.js"></script>
<!-- 自定义js -->
<script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/common/js/layer_show.js"></script>
<!-- iCheck -->
<script src="__PUBLIC__/admin/js/plugins/iCheck/icheck.min.js"></script>
<!-- Peity -->
<script src="__PUBLIC__/admin/js/demo/peity-demo.js"></script>
<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
    });

    function switch_off(obj,id) {
        var status=$(obj).is(':checked');
        var state;
        if(status==false){
             state = 2;
        }else{
             state = 1;
        }
        //alert(state);return;
        $.post('__MODULE__/System/switch_offON',{id:id,state:state},function (data) {
            if(data.status==1){
                layer.msg(data.msg);
            }else{
                layer.msg(data.error);
            }
        })
    }


    function Power_delete(obj,id) {
        layer.confirm('确认删除吗？', function () {
            if (id == '') {
                layer.msg('操作错误，请刷新再试');
                return false;
            }
            $.post('__MODULE__/System/menu_parent',{menu_id: id}, function (data){  //判断是否为主菜单
                if(data.status==1){
                    layer.confirm('您删除的为主节点,删除后其子节点已将被删除，是否继续？', function () {
                        $.post('__MODULE__/System/power_delete', {menu_id: id}, function (data) {
                            if (data.status == 1) {
                                layer.msg(data.msg);
                                $(obj).parents("tr").remove();
                            } else {
                                layer.msg(data.error);
                            }
                        })
                    })
                }else{
                    $.post('__MODULE__/System/power_delete', {menu_id: id}, function (data) {
                        if (data.status == 1) {
                            layer.msg(data.msg);
                            $(obj).parents("tr").remove();
                        } else {
                            layer.msg(data.error);
                        }
                    })
                }
            });
        })
    }
    function power_add(title,url,w,h) {
        layer_show(title,url,w,h);
    }
    function Power_save(t,u,w,h) {
        layer_show(t,u,w,h);
    }

</script>
</body>
</html>
